package jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class jdbcdemo3
{
    public static void main(String[] args) throws ClassNotFoundException, SQLException {
        Class.forName("com.mysql.cj.jdbc.Driver");
        System.out.println("正在连接");
        Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/tedu?characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true",
                "root",
                "root");
        System.out.println("连接成功");
        Statement sa = con.createStatement();
        /*
        UPDATE USER SET PASSWORD='000000' WHERE USERNAME='张三'
         */
        String sql = "UPDATE USER SET PASSWORD='000000' WHERE USERNAME='张三'";
        int count = sa.executeUpdate(sql);
        System.out.println(count > 0 ? "成功" : "失败");
        sa.close();
    }
}
